package learn.advance.collection1;

import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;

class Demo1Collection {
    public static void Test() {
        Collection<String> coll = new HashSet<>();
        System.out.println(coll);

        boolean b1 = coll.add("小明");
        System.out.println("b1:" + b1);
        System.out.println(coll);

        coll.add("小军");
        coll.add("小红");
        System.out.println(coll);

        boolean b2 = coll.remove("小军");
        System.out.println(coll);

        boolean b3 = coll.contains("小军");
        System.out.println("b3" + b3);

        int size3 = coll.size();
        System.out.println("size3: " + size3);

        Object[] arr = coll.toArray();
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

        coll.clear();
        System.out.println(coll);
        System.out.println(coll.isEmpty());
    }
}


public class TestCollection {
    public static void main(String[] args) {
        Demo1Collection.Test();
    }

}
